﻿<controls:ChildWindow xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="MyFloridaHouse.SilverlightOpenDistricts.DistrictRenumberDialog"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           Width="400" Height="300" 
           Title="Renumber Districts">
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" Grid.ColumnSpan="2" Margin="5">
            <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="5" />
            <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="5" />
        </StackPanel>

        <sdk:Label Content="Old District Number" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" />

        <sdk:Label Content="New District Number" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center"  />

        <ListBox Grid.Row="2" Grid.Column="0" Margin="0" Grid.ColumnSpan="2"  
                                     ItemsSource="{Binding districtRenumberList}"  
                                     SelectedIndex="{Binding districtRenumberListSelectedIndex, Mode=TwoWay}" Background="Azure" 
                                     VerticalAlignment="Stretch"
                                     HorizontalAlignment="Stretch"
                            >
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel UseLayoutRounding="True" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            
            <ListBox.Template>
                <ControlTemplate>
                    <ScrollViewer>
                        <ItemsPresenter />
                    </ScrollViewer>
                </ControlTemplate>
            </ListBox.Template>
            
            <ListBox.ItemTemplate >
                
                <DataTemplate >
                    <Border BorderThickness="2" 
                            BorderBrush="{Binding isSelectedForRenumber, Mode=OneWay, Converter={StaticResource ConvertActiveBrushFromBool}}" 
                            Background="{Binding isActiveRenumberElement, Mode=OneWay, Converter={StaticResource ConvertIndicatorBrushFromBool}}"  >
                        <Grid x:Name="LayoutRoot" Margin="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="50" />
                                <ColumnDefinition Width="50" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            
                            <sdk:Label Grid.Column="0" Content="{Binding sourceDistrictID}"/>
                            <TextBox Grid.Column="1" Text="{Binding targetDistrictID}"/>
                        </Grid>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>

        </ListBox>

    </Grid>
</controls:ChildWindow>